
<%@ page import="com.surelution.projects.crm.MessageBoard" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:javascript library="jquery" plugin="jquery"/>
        <r:require module="jquery-ui"/>
        <r:layoutResources/>
        <g:set var="entityName" value="${message(code: 'messageBoard.label', default: 'MessageBoard')}" />
        <title><g:message code="default.publicList.label"/></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
        </div>
        <div class="body">
            <h1>
            	<g:message code="default.publicList.label" />
            	<sec:ifLoggedIn>
               		<input type="button" onclick="createMessage()" value="添加新公告" />
               	</sec:ifLoggedIn>
            </h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="dialog" >
                <table style="width:600px;">
                    <tbody>
                        <g:each in="${messageBoardInstanceList}" status="i" var="messageBoardInstance">
                    	<tr class="prop">
                            <td valign="top"  style="font-weight:bold;font-family:楷体, arial, helvetica, sans-serif;text-align:left;">
                            	${i+1}<g:if test="${messageBoardInstance.title.size()>=10}"><label title="${messageBoardInstance.title}" style="color:#16457d;">${messageBoardInstance.title.substring(0,9)}</label></g:if>
                           		<g:if test="${messageBoardInstance.title.size()<10}"><label style="color:#16457d;">${messageBoardInstance.title}</label></g:if>
                            	(发布者:<label title="${messageBoardInstance.station?.name}">${messageBoardInstance.user})</label>
                            	<g:link action="show" id="${messageBoardInstance.id}">详情</g:link>
                            </td>

                            <td valign="top" style="color:gray;text-align:right;">
                            	<g:formatDate date="${messageBoardInstance.createTime}" />
                            </td>
							
                        </tr>
                        
                        <tr class="prop">
                            <td valign="top" class="name2">
	                            <g:if test="${messageBoardInstance.description.size()>=30}"><label title="${messageBoardInstance.description}">${messageBoardInstance.description.substring(0,29)}</label> </g:if>
                           		<g:if test="${messageBoardInstance.description.size()<30}"><label>${messageBoardInstance.description}</label></g:if>
                           	</td>
                           	
                           	<td valign="top" class="value2">
				            <sec:ifAnyGranted roles="ROLE_ADMIN">
								<g:form style="width:150px;text-align:right;">
				                    <g:hiddenField name="id" value="${messageBoardInstance.id}" />
				                    <g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
	                    			<g:actionSubmit class="reply" action="create" value="${message(code: 'default.button.reply.label', default: 'Reply')}"/>
			               		</g:form>
			               	</sec:ifAnyGranted>
							</td>
                        </tr>
					</g:each>
                    </tbody>
                </table>

            </div>
            <div class="paginateButtons"  style="width:600px;">
                <g:paginate total="${messageBoardInstanceTotal}" />
            </div>
            <script type="text/javascript">
		        $(function() {
		    		$( "#newMessage" ).dialog({autoOpen:false, modal:true, height:300, width:450});
		    	});
		
		    	function createMessage() {
		    		$( "#newMessage" ).dialog("open");
		        }
			</script>
			 <div id="newMessage" title="添加新公告！" >
          	<g:form action="save" >
                <div class="dialog2">
                    <table >
                        <tbody>
							<tr class="prop">
                                <td valign="top" class="name">
                                    <label for="title"><g:message code="messageBoard.title.label" default="Title" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: messageBoardInstance, field: 'title', 'errors')}" style="width:200px;">
                                	<g:hiddenField name="replyTo.id" value="${messageBoardInstance?.replyTo?.id }"/>
                                    <g:textField name="title" value="${messageBoardInstance?.title}" style="width:180px;" />(必填)
                                </td>
                            </tr>    
                                                
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="description"><g:message code="messageBoard.description.label" default="Description" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: messageBoardInstance, field: 'description', 'errors')}">
                                    <g:textArea name="description" rows="8" cols="50" value="${messageBoardInstance?.description}" />
                                </td>
                            </tr>
                          	
                          	<tr class="prop">
                  				<td colspan="2" style="padding:0 0 0 180px;">
                  					<g:actionSubmit name="create" class="save" action="savePublic" value="${message(code: 'default.button.create.label', default: 'Create')}" />
                  				</td>
                          	</tr>
                        </tbody>
                    </table>
                </div>
            </g:form>
            </div>
        </div>
    </body>
</html>
